package i18n;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

import org.mca.mcaweb.util.McawebException;

public class MsgUtil {
	
	public static void addGlobalMessage(String message, String detail) {
        FacesMessage facesMessage = new FacesMessage(message, detail);
        FacesContext.getCurrentInstance().addMessage(null, facesMessage);
    }

	public static void addErrorMessage(String message, String detail) {
        FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, message, detail);
        FacesContext.getCurrentInstance().addMessage(null, facesMessage);
    }

    public static void addWarnMessage(String message) {
        FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_WARN, message, null);
        FacesContext.getCurrentInstance().addMessage(null, facesMessage);
    }

    public static void addFatalMessage(String message) {
        FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_FATAL, message, null);
        FacesContext.getCurrentInstance().addMessage(null, facesMessage);
    }

    public static void addMessage(McawebException e) {
        FacesMessage facesMessage = new FacesMessage(e.getSeverity(), e.getFriendlyMessage(), e.getMessage());
        FacesContext.getCurrentInstance().addMessage(null, facesMessage);
    }
	

}
